/*
 * Created by JFormDesigner on Tue Dec 27 15:19:47 ICT 2011
 */

package View;

import java.awt.*;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Vector;

import javax.swing.*;
import javax.swing.border.*;
import org.jdesktop.swingx.*;

import Dao.MakeNewDaoHelper;

/**
 * @author Khainx
 */
public class MakeNewView extends JPanel {
	private MakeNewDaoHelper dao = new MakeNewDaoHelper();

	public MakeNewView() {
		initComponents();
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY
		// //GEN-BEGIN:initComponents
		panel1 = new JPanel();
		label1 = new JLabel();
		panel2 = new JPanel();
		panel4 = new JPanel();
		label2 = new JLabel();
		cbxNumber = new JComboBox();
		label4 = new JLabel();
		xDatePicker1 = new JXDatePicker();
		label3 = new JLabel();
		cbxName = new JComboBox();
		label5 = new JLabel();
		xDatePicker2 = new JXDatePicker();
		panel5 = new JPanel();
		label6 = new JLabel();
		cbxFromLocation = new JComboBox();
		label7 = new JLabel();
		cbxToLocation = new JComboBox();
		label8 = new JLabel();
		cbxFromProject = new JComboBox();
		label9 = new JLabel();
		cbxToProject = new JComboBox();
		label10 = new JLabel();
		cbxFromDepartment = new JComboBox();
		label11 = new JLabel();
		cbxToDepartment = new JComboBox();
		lblAllowance = new JLabel();
		panel3 = new JPanel();
		btnMake = new JButton();
		btnExit = new JButton();

		//======== this ========
		setLayout(new BorderLayout());

		//======== panel1 ========
		{
			panel1.setBorder(new EtchedBorder());
			panel1.setLayout(new FlowLayout());

			//---- label1 ----
			label1.setText("Make Transfer");
			label1.setFont(new Font("Tahoma", Font.PLAIN, 30));
			panel1.add(label1);
		}
		add(panel1, BorderLayout.NORTH);

		//======== panel2 ========
		{
			panel2.setLayout(new BorderLayout());

			//======== panel4 ========
			{
				panel4.setBorder(new TitledBorder("Transfer Info"));
				panel4.setLayout(new GridBagLayout());
				((GridBagLayout)panel4.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
				((GridBagLayout)panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
				((GridBagLayout)panel4.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};
				((GridBagLayout)panel4.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0E-4};

				//---- label2 ----
				label2.setText("Employee Number");
				label2.setPreferredSize(new Dimension(110, 14));
				panel4.add(label2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxNumber ----
				cbxNumber.setPreferredSize(new Dimension(112, 22));
				panel4.add(cbxNumber, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- label4 ----
				label4.setText("Join Date");
				label4.setPreferredSize(new Dimension(84, 14));
				panel4.add(label4, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));
				panel4.add(xDatePicker1, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 0), 0, 0));

				//---- label3 ----
				label3.setText("Employee Name");
				label3.setPreferredSize(new Dimension(110, 14));
				label3.setMaximumSize(new Dimension(84, 14));
				label3.setMinimumSize(new Dimension(84, 14));
				panel4.add(label3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 0, 5), 0, 0));

				//---- cbxName ----
				cbxName.setPreferredSize(new Dimension(112, 22));
				panel4.add(cbxName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 0, 5), 0, 0));

				//---- label5 ----
				label5.setText("Relieve Date");
				label5.setPreferredSize(new Dimension(84, 14));
				panel4.add(label5, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 0, 5), 0, 0));
				panel4.add(xDatePicker2, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 0, 0), 0, 0));
			}
			panel2.add(panel4, BorderLayout.NORTH);

			//======== panel5 ========
			{
				panel5.setBorder(new TitledBorder("Transfer Detail"));
				panel5.setLayout(new GridBagLayout());
				((GridBagLayout)panel5.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
				((GridBagLayout)panel5.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
				((GridBagLayout)panel5.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};
				((GridBagLayout)panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};

				//---- label6 ----
				label6.setText("From Location");
				label6.setPreferredSize(new Dimension(110, 14));
				panel5.add(label6, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxFromLocation ----
				cbxFromLocation.setPreferredSize(new Dimension(112, 22));
				panel5.add(cbxFromLocation, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- label7 ----
				label7.setText("To Location");
				label7.setPreferredSize(new Dimension(84, 14));
				panel5.add(label7, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxToLocation ----
				cbxToLocation.setPreferredSize(new Dimension(112, 22));
				panel5.add(cbxToLocation, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 0), 0, 0));

				//---- label8 ----
				label8.setText("From Project");
				label8.setPreferredSize(new Dimension(110, 14));
				panel5.add(label8, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxFromProject ----
				cbxFromProject.setPreferredSize(new Dimension(112, 22));
				panel5.add(cbxFromProject, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- label9 ----
				label9.setText("To Project");
				label9.setPreferredSize(new Dimension(84, 14));
				panel5.add(label9, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxToProject ----
				cbxToProject.setPreferredSize(new Dimension(112, 22));
				panel5.add(cbxToProject, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 0), 0, 0));

				//---- label10 ----
				label10.setText("From Department");
				label10.setPreferredSize(new Dimension(110, 14));
				panel5.add(label10, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxFromDepartment ----
				cbxFromDepartment.setPreferredSize(new Dimension(112, 22));
				panel5.add(cbxFromDepartment, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- label11 ----
				label11.setText("To Department");
				label11.setPreferredSize(new Dimension(84, 14));
				panel5.add(label11, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 5), 0, 0));

				//---- cbxToDepartment ----
				cbxToDepartment.setPreferredSize(new Dimension(112, 22));
				panel5.add(cbxToDepartment, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 5, 0), 0, 0));
				panel5.add(lblAllowance, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 0, 0), 0, 0));
			}
			panel2.add(panel5, BorderLayout.CENTER);
		}
		add(panel2, BorderLayout.CENTER);

		//======== panel3 ========
		{
			panel3.setLayout(new FlowLayout());

			//---- btnMake ----
			btnMake.setText("Make");
			panel3.add(btnMake);

			//---- btnExit ----
			btnExit.setText("Exit");
			panel3.add(btnExit);
		}
		add(panel3, BorderLayout.SOUTH);
		// //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY
	// //GEN-BEGIN:variables
	private JPanel panel1;
	private JLabel label1;
	private JPanel panel2;
	private JPanel panel4;
	private JLabel label2;
	private JComboBox cbxNumber;
	private JLabel label4;
	private JXDatePicker xDatePicker1;
	private JLabel label3;
	private JComboBox cbxName;
	private JLabel label5;
	private JXDatePicker xDatePicker2;
	private JPanel panel5;
	private JLabel label6;
	private JComboBox cbxFromLocation;
	private JLabel label7;
	private JComboBox cbxToLocation;
	private JLabel label8;
	private JComboBox cbxFromProject;
	private JLabel label9;
	private JComboBox cbxToProject;
	private JLabel label10;
	private JComboBox cbxFromDepartment;
	private JLabel label11;
	private JComboBox cbxToDepartment;
	private JLabel lblAllowance;
	private JPanel panel3;
	private JButton btnMake;
	private JButton btnExit;
	// JFormDesigner - End of variables declaration //GEN-END:variables
	public String getEmpNumber() {
		return this.cbxNumber.getSelectedItem().toString();
	}

	public String getEmpName() {
		return this.cbxName.getSelectedItem().toString();
	}

	public String getJoinDate(){
		return this.xDatePicker1.toString();
	}
	public String getRelieve(){
		return this.xDatePicker2.toString();
	}
	public String getFromLocation() {
		return this.cbxFromLocation.getSelectedItem().toString();
	}

	public String getToLocation() {
		return this.cbxToLocation.getSelectedItem().toString();
	}

	public String getFromDepartment() {
		return this.cbxFromDepartment.getSelectedItem().toString();
	}

	public String getToDepartment() {
		return this.cbxToDepartment.getSelectedItem().toString();
	}

	public String getFromProject() {
		return this.cbxFromProject.getSelectedItem().toString();
	}

	public String getToProject() {
		return this.cbxToProject.getSelectedItem().toString();
	}

	public void setText(String string) {
		this.lblAllowance.setText(string);
	}

	public void doMake(ActionListener listener) {
		this.btnMake.addActionListener(listener);
	}

	public void doExit(ActionListener listener) {
		this.btnExit.addActionListener(listener);
	}

	public void loadLocation() throws SQLException, ClassNotFoundException,
			IOException {
		for (String item : dao.loadLocation()) {
			this.cbxFromLocation.addItem(item);
			this.cbxToLocation.addItem(item);
		}
	}

	public void loadProject() throws SQLException, ClassNotFoundException,
			IOException {
		for (String item : dao.loadProject()) {
			this.cbxFromProject.addItem(item);
			this.cbxToProject.addItem(item);
		}

	}

	public void loadDepartment() throws SQLException, ClassNotFoundException,
			IOException {
		for (String item : dao.loadDepartment()) {
			this.cbxFromDepartment.addItem(item);
			this.cbxToDepartment.addItem(item);
		}

	}

	public void loadNumber() throws SQLException, ClassNotFoundException,
			IOException {
		for (String item : dao.loadNumber()) {
			this.cbxNumber.addItem(item);
		}

	}

	public void loadName() throws SQLException, ClassNotFoundException,
			IOException {
		for (String item : dao.loadName()) {
			this.cbxName.addItem(item);
		}

	}

}
